<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:gb="http://giava.by/common/base"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Lista Notizie" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="richnews" />
	</ui:define>
	<ui:define name="content">
		<h:form>
			<center>
				<p:panel header="Lista Notizie">
					<h:panelGrid columns="5">
						<h:outputLabel for="titolo" value="Titolo:" />
						<h:inputText id="titolo"
							value="#{richNewsController.search.obj.title}" />

						<h:outputLabel for="tipo" value="Seleziona tipo:" />
						<h:selectOneMenu id="tipo"
							value="#{richNewsController.search.obj.richNewsType.id}">
							<f:selectItems value="#{richNewsTypeItems}" />
						</h:selectOneMenu>
						<p:commandButton action="#{richNewsController.reloadAjax}"
							value="Cerca" ajax="true" immediate="false" update="newsList" />

					</h:panelGrid>
					<br />

					<p:dataTable id="newsList" rowIndexVar="rowIndex" var="notizia"
						value="#{richNewsController.model}"
						rows="#{richNewsController.pageSize}" paginator="true"
						dynamic="true">
						<p:column width="50">
							<h:outputText value="#{rowIndex+1}" />
						</p:column>

						<p:column width="300">
							<f:facet name="header">titolo</f:facet>
							<h:outputText value="#{notizia.title}" />
						</p:column>

						<p:column width="100">
							<f:facet name="header">data</f:facet>
							<h:outputText value="#{notizia.date}">
								<f:convertDateTime pattern="dd/MM/yyyy HH:mm"
									timeZone="Europe/Rome" />
							</h:outputText>
						</p:column>

						<p:column width="100">
							<f:facet name="header">tipo</f:facet>
							<h:outputText value="#{notizia.richNewsType.name}" />
						</p:column>

						<p:column width="200">
							<f:facet name="header">operazioni</f:facet>
							<gb:center>
								<h:commandLink action="#{richNewsController.viewElement}"
									value="vedi" />
								<br />
								<h:commandLink action="#{richNewsController.modElement}"
									value="modifica testi" />
								<br />
								<h:commandLink action="#{richNewsController.modDocuments}"
									value="modifica documenti" />
							</gb:center>
						</p:column>
					</p:dataTable>
				</p:panel>
				<br /> <br />

				<h:panelGrid columns="1">
					<h:commandButton id="creaNotizia"
						action="#{richNewsController.addElement}" value="Aggiungi" />
				</h:panelGrid>
			</center>
		</h:form>
	</ui:define>
</ui:composition>
